/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.mortbay.jetty.pico.dao.employee;

import java.util.List;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;
import org.mortbay.jetty.pico.entities.Employee;

/**
 *
 * @author godfather
 */
public class EmployeeDAOImpl implements EmployeeDAO{

    
    public List<Employee> getList() {
        return session.getNamedQuery("Employee.findAll").list();
    }

    public Employee find(String id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void save(Employee t) {
        this.session.persist(t);
    }

    public void remove(Employee t) {
        int result = session.createQuery("delete from Employee e where e.idEmp = ?").setString(0, t.getIdEmp()).executeUpdate();
        System.out.println("result: " + result);
    }

    public void removeByID(String o) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    /*
     * IOC
     */
    @Inject 
    private Session session;
    
    /*
     * Getter and Setter
     * 
     */
    public Session getSession() {
        return session;
    }

    public void setSession(Session session) {
        this.session = session;
    }
    
}
